package windows;

import java.util.Collection;

import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import interfaces.CollectionView;
import interfaces.Controller;
import interfaces.LabelClick;

public class DefaultCollectionView implements CollectionView{
	
	@Override
	public JPanel getView(Collection<?> collection, JFrame window, Controller controller) {
		JPanel panel = new JPanel();
		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
		for (Object object : collection) {
			JLabel label = new JLabel(object.toString());
			if(!object.getClass().isPrimitive() && !object.getClass().equals(String.class) && !object.getClass().equals(Integer.class) && !object.getClass().equals(Double.class) && !object.getClass().equals(Boolean.class)){
				label.addMouseListener(new LabelClick(object, window, controller));
			}
			panel.add(label);
		}
		return panel;
	}
}
